package org.dxy.infrastructure.persistent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dxy.infrastructure.persistent.mapper.WorkstationRuntimeViewMapper;
import org.dxy.infrastructure.persistent.po.query.WorkstationRuntimeViewPo;
import org.dxy.infrastructure.persistent.service.WorkstationRuntimeViewService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 工位运行时状态视图服务实现
 * @author dxy
 * @createTime 2025/10/19
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class WorkstationRuntimeViewServiceImpl extends ServiceImpl<WorkstationRuntimeViewMapper, WorkstationRuntimeViewPo> 
        implements WorkstationRuntimeViewService {

    @Override
    public List<WorkstationRuntimeViewPo> getAllRuntimeStatus() {
        return this.list(new LambdaQueryWrapper<WorkstationRuntimeViewPo>()
                .orderByAsc(WorkstationRuntimeViewPo::getWorkstationId));
    }

    @Override
    public WorkstationRuntimeViewPo getByWorkstationId(Long workstationId) {
        return this.getOne(new LambdaQueryWrapper<WorkstationRuntimeViewPo>()
                .eq(WorkstationRuntimeViewPo::getWorkstationId, workstationId));
    }

    @Override
    public List<WorkstationRuntimeViewPo> getByStatus(String status) {
        return this.list(new LambdaQueryWrapper<WorkstationRuntimeViewPo>()
                .eq(WorkstationRuntimeViewPo::getCurrentStatus, status)
                .orderByAsc(WorkstationRuntimeViewPo::getWorkstationId));
    }
}